version: "3.12"
services:
  db:
    image: postgres:15
    container_name: db_app
    command: -p 5433
    expose:
      - 5433
    env_file:
      - .env-docker
    ports:
      - 5433:5433

  redis:
    image: redis:7
    container_name: redis_app
    command: --port 5371
    expose:
      - 5371
    env_file:
      - .env-docker
    ports:
      - 5371:5371

  basic-app:
    build:
      context: .
    env_file:
      - .env-docker
    container_name: basic_app
    command: gunicorn app.basic.basic_server:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind=0.0.0.0:80
    ports:
      - 8001:80
    depends_on:
      - db
      - redis

  inventory-app:
    build:
      context: .
    env_file:
      - .env-docker
    container_name: inventory_app
    command: gunicorn app.inventory.inventory_server:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind=0.0.0.0:80
    ports:
      - 8002:80
    depends_on:
      - basic-app
      - db
      - redis

  bff-app:
    build:
      context: .
    env_file:
      - .env-docker
    container_name: bff_app
    command: gunicorn app.bff.bff_server:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind=0.0.0.0:80
    ports:
      - 8003:80
    depends_on:
      - basic-app
      - inventory-app
      - db
      - redis

  terminal-app:
    build:
      context: .
    env_file:
      - .env-docker
    container_name: terminal_app
    command: gunicorn app.terminal.server:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind=0.0.0.0:80
    ports:
      - 8004:80
    depends_on:
      - db
      - redis

  celery:
    build:
      context: .
    env_file:
      - .env-docker
    container_name: celery_app
    command: celery --app=core.helpers.celery.celery:celery_app worker -l INFO
    depends_on:
      - redis

  flower:
    build:
      context: .
    env_file:
      - .env-docker
    container_name: flower_app
    command: celery --app=core.helpers.celery.celery:celery_app flower
    depends_on:
      - redis
      - celery
    ports:
      - 5555:5555